package com.isoft.send;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Random;

public class SendMain {

	public static void main(String[] args) throws Exception {
		ServerSocket ser = new ServerSocket(9279);
		while (true) {
			final Socket soc = ser.accept();
			
			new Thread() {
				public void run() {
					try {
						InputStream is = soc.getInputStream();
						OutputStream os = soc.getOutputStream();
						Random r=new Random();
						while (true) {
							double hum=Math.round(r.nextDouble()*100);
							double tmp=Math.round(r.nextDouble()*100);
							double light=Math.round(r.nextDouble()*150);
							String ss=String.valueOf(hum)+","+String.valueOf(tmp)+","+String.valueOf(light);
							os.write(ss.getBytes());
							System.out.println(ss);
							Thread.sleep(1000);
						}
					} catch (IOException e) {						
						e.printStackTrace();
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}					
				}
			}.start();
		}

	}

}
